package jbelab3productmanager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Product {
	private int prdID;
	private String prdName;
	private String supplier;
	private float price;
	private int quanlity;
	private BufferedReader br;

	public Product() {
		super();
	}

	public Product(int prdID, String prdName, String supplier, float price,
			int quanlity) {
		super();
		this.prdID = prdID;
		this.prdName = prdName;
		this.supplier = supplier;
		this.price = price;
		this.quanlity = quanlity;
	}

	public int getPrdID() {
		return prdID;
	}

	public void setPrdID(int prdID) {
		this.prdID = prdID;
	}

	public String getPrdName() {
		return prdName;
	}

	public void setPrdName(String prdName) {
		this.prdName = prdName;
	}

	public String getSupplier() {
		return supplier;
	}

	public void setSupplier(String supplier) {
		this.supplier = supplier;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public int getQuanlity() {
		return quanlity;
	}

	public void setQuanlity(int quanlity) {
		this.quanlity = quanlity;
	}

	Product addProduct() throws NumberFormatException, IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("        Add new Product");
		System.out.println("================================");
		System.out.print("Enter Product ID: ");
		prdID = Integer.parseInt(br.readLine());
		setPrdID(prdID);
		System.out.print("Enter Product Name: ");
		prdName = br.readLine();
		setPrdName(prdName);
		System.out.print("Enter Supplier: ");
		supplier = br.readLine();
		setSupplier(supplier);
		System.out.print("Enter Price: ");
		price = Float.parseFloat(br.readLine());
		setPrice(price);
		System.out.print("Enter Quanlity: ");
		quanlity = Integer.parseInt(br.readLine());
		setQuanlity(quanlity);
		System.out.println("================================");
		Product pr = new Product(prdID, prdName, supplier, price, quanlity);
		return pr;
	}

	void showProduct() {
		System.out.println("        Product Information");
		System.out.println("================================");
		System.out.println("Product ID: " + getPrdID());
		System.out.println("Product Name: " + getPrdName());
		System.out.println("Supplier: " + getSupplier());
		System.out.println("Price: " + getPrice());
		System.out.println("Quanlity: " + getQuanlity());
		System.out.println("Total Money: " + moneyComputing());
		System.out.println("================================");
	}

	float moneyComputing() {
		float money = 0;
		money = getPrice() * getQuanlity();
		return money;
	}
}
